<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>学生通行码</title>
    <script src="https://cdn.jsdelivr.net/npm/davidshimjs-qrcodejs@0.0.2/qrcode.min.js"></script>
    <style>
        html,body{
  height: 100%;
  margin: 0;
  background-color: #F8F8F8;
}
        .bg {
  background-color: #3872EE;
  height: 24.5%;
}
.date {
    text-align: center;
}
.code-box-wrap {
  height: 72%;
  width: 100%;
  /* margin: 54px; */
  /* border-radius: 5px; */
  /* position: absolute; */
  margin-top: -180px;
  /* top: 30px; */
  /* top: 0; */
  /* background-color: yellow; */
  box-sizing: border-box;
  padding: 30px;
}
.code-area {
  height: 100%;
  overflow: hidden;
  border-radius: 5px;
  background: white;
}
.date {
    margin: 12px 0 ;
}
.code-real-time {
  font-size: 42px;
  line-height: 1;
  font-weight: bold;
  margin: 0;
}
.ps-info {
  width: calc(100%-16)px;
  /* padding: 5px; */
  /* margin: 10px; */
  margin: 0 8px;
  font-size: 18px;
  border-top: 1px solid #FAFAFA;
  display: flex;
  /* flex: 1; */
  justify-content: space-between;
}
.person {
  /* display: flex;
   */
  text-align: center;
  font-size: 18px;
  margin-top: 10px;
}
.person .button {
  margin-left: 10px;
  color: #3871C9;
}
#qrcode {
  margin-top: 5px;
  display: flex;
  justify-content: center;
}
.effect-time {
    margin: 5px 0 0 30px;
}
.info-card {
    margin-left: 40px;
}
.info-card .type {
    color: #b7b2b2;
}
.info-card p {
    margin: 8px;
}
.footer {
  color: #3871C9;
  font-size: 18px;
  text-align: center;
}
.footer .sep {
    color: #b7b2b2;
}
    </style>
</head>
<body>
  <div class="bg"></div>
  <div class="code-box-wrap">
    <div class="code-area">
      <div class="date">
        <p id= 'day' class="code-real-time">{{month}}月{{day}}日</p>
        <p id= 'clock' class="code-real-time">{{hour}}:{{minute}}:{{second}}</p>
      </div>
      <div class="ps-info">
        <span>经济管理学院</span>
        <span>2017339901246</span>
      </div>
      <!-- <qr-dropzone/> -->
      <div id="qrcode"></div>
      <div class="person">
        <span>黄仁浩</span>
        <span class="button" id="refresh">刷新</span>
      </div>
    </div>
  </div>
    <p class="effect-time">2020-9-29 至 <span id ='effectTime'>2021-1-24</span></p>
    <div class="info-card">
        <p><span class="type">通行码类型: </span><span>临时通行码</span></p>
        <p><span class="type">剩余次数: </span><span>9983</span></p>
        <p><span class="type">第一次刷卡时间: </span><span>2020-10-22 18:17:33</span></p>
    </div>
    <p class="footer">
        <span>通行记录</span>
        <span class="sep">|</span>
        <span>普通码</span>
    </p>
<script type="text/javascript">
    function wrapTime (str) {
        str = String(str)
        if (str.length < 2) return '0' + str
        return str
    }
    setInterval(() => {
        const date = new Date()
        const dayStr = (date.getMonth()+1) + '月' + date.getDate() + '日'
        const timeStr = wrapTime(date.getHours()) + ':' + wrapTime(date.getMinutes()) + ':' + wrapTime(date.getSeconds())
        document.getElementById('day').innerText = dayStr
        document.getElementById('clock').innerText = timeStr
        document.getElementById('effectTime').innerText = date.getFullYear() + '-' + (date.getMonth()+1) + '-' + date.getDate()
    },1000)
    qrcodeSource = ['ifjahgjahsjfhdjkshajkhgjdshajkhjkgfjdskajfkladsajkfj', 'lovedfjakdsjfkldjaskfjkldajlkfjadskljfkfdsafdsfdsa', 'jingjingdanfnklasdjfkjasdkljfklsdajkljflkdsjafdsafds']
    var qrcode = new QRCode(document.getElementById("qrcode"), {
        text: "http://jindo.dev.naver.com/collie",
        width: 290,
        height: 290,
        colorDark : '#3974F4',
        colorLight : "#ffffff",
        correctLevel : QRCode.CorrectLevel.H
    });
    document.getElementById('refresh').addEventListener('click', () => {
      qrcode.clear()
      qrcode.makeCode(qrcodeSource[Math.floor(Math.random()*qrcodeSource.length)])
    })
</script>
</body>
</html>